/*
 * @Author: szx
 * @Date: 2022-03-03 14:05:25
 * @LastEditTime: 2022-03-03 14:10:57
 * @Description:
 * @FilePath: \leetcode\100-199\111\111_2.js
 */

/**
 * @param {TreeNode} root
 * @return {number}
 */
var minDepth = function (root) {
    if (!root) return 0;
    if (!root.left && root.right) return 1 + minDepth(root.right);
    if (!root.right && root.left) return 1 + minDepth(root.left);
    return 1 + Math.min(minDepth(root.left), minDepth(root.right));
};
